package com.frogs.ucenter.v1.request;

import javax.servlet.http.HttpServletRequest;

import org.owasp.esapi.ESAPI;

import com.frogs.framework.util.StringUtil;
import com.frogs.framework.web.HttpRequestInfo;
import com.frogs.system.util.ApiUrlParamEnum;
import com.frogs.system.util.SexEnum;
import com.frogs.system.web.api.request.Request;
import com.frogs.system.web.exception.RequestIllegalException;

/**
 * 用户投诉留言
 *
 * @author wushubin
 * 
 */
public class UserFeedbackAddRequest extends Request{

	/**
	 * 
	 */
	private static final long serialVersionUID = -2862378293178358815L;

	private String userName;

    private String phone;

    private String email;

    private String content;
	
    private String referUrl;
    
    private Integer sex;
    
	public UserFeedbackAddRequest(){
	}
	
	@Override
	public void parse(HttpServletRequest request) {
		
		HttpRequestInfo requestInfo = new HttpRequestInfo(request);
		
		this.userName = StringUtil.fixHtml(requestInfo.getParameter(ApiUrlParamEnum.username.getParamName(), "-"));
		this.phone = requestInfo.getParameter(ApiUrlParamEnum.phone.getParamName(), "");
		this.email = requestInfo.getParameter(ApiUrlParamEnum.email.getParamName(), "-");
		this.content = StringUtil.fixHtml(requestInfo.getParameter(ApiUrlParamEnum.content.getParamName(), "-"));
		this.referUrl = requestInfo.getParameter(ApiUrlParamEnum.traceReferUrl.getParamName(), "-");
		this.sex = requestInfo.getIntParameter(ApiUrlParamEnum.sex.getParamName(),SexEnum.UNKNOW.getId() );
		
		if ( StringUtil.isEmpty(phone) || !StringUtil.isMobilePhone(phone)) {
			throw new RequestIllegalException("手机号码有误，请输入正确的手机号码!");
		}
		
		if(StringUtil.isEmpty(content)){
			throw new RequestIllegalException("error content!");
		}
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getReferUrl() {
		return referUrl;
	}

	public void setReferUrl(String referUrl) {
		this.referUrl = referUrl;
	}

	public Integer getSex() {
		return sex;
	}

	public void setSex(Integer sex) {
		this.sex = sex;
	}
	
	
}
